package com.dong.es.entity.searchparam.page;

import co.elastic.clients.elasticsearch.core.SearchRequest;
import com.dong.es.entity.EsBaseDTO;

/**
 * @description: Es From Size 分页参数
 * @author: 陈瑞东
 * @create: 2022-06-23 10:40
 */
public class EsFromSizePageParam extends EsPageParam{
    private static final long serialVersionUID = 4048150089271348476L;

    // 数据开始位置
    private Integer from;
    // 数据条数
    private Integer size;

    public EsFromSizePageParam(Integer from, Integer size) {
        this.from = from;
        this.size = size;
    }

    @Override
    protected boolean valid(EsBaseDTO esBaseDTO) {
        return from != null && size != null;
    }

    @Override
    public void loadTo(SearchRequest.Builder target) {
        target.from(from).size(size);
    }
}
